﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using Ooaavee.Data.Model;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace Ooaavee.Data.Queries
{
    /// <summary>
    /// A dependency.
    /// </summary>
    [DataContract]
    [DebuggerDisplay("{DebuggerDisplay,nq}")]
    public sealed class Dependency
    {
        [DataMember]
        private QueryResult _data;

        [DataMember]
        public QueryResultRow Parent { set; get; }

        [DataMember]
        public Column Column { set; get; }

        public QueryResult Data
        {
            get
            {
                if (_data == null)
                {
                    _data = QueryFactory.CreateChildTableQuery(this).Execute();
                }
                return _data;
            }
        }

        #region Debugger
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "See DebuggerDisplayAttribute marked on this class.")]
        [DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private string DebuggerDisplay { get { return ""; } }
        #endregion

        public override string ToString()
        {
            return base.ToString();
            //return string.Format("{0}.{1} -> {2}.{3}", Column.Parent.ToString(), Column.ToString(), col.LinkedTo.Table.ToString(), col.LinkedTo.ToString());
        }
    }

}
